package com.koomii.rabbitmq.demo.message.sender;

import org.springframework.amqp.core.Message;
import org.springframework.amqp.core.MessageProperties;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class DemoRabbitSender {
	@Autowired
	RabbitTemplate rabbitTemplate;
	
	public void send(String message) {
		long start = System.currentTimeMillis();
//		MessageProperties messageProperties = new MessageProperties();
//		messageProperties.setDelay(0);
//		Message msg = new Message(message.getBytes(), messageProperties);
//		rabbitTemplate.send("queue_test", msg);
		rabbitTemplate.convertAndSend("queue_test", message);
		System.out.println("发送amqp消息耗时："+(System.currentTimeMillis() - start)+"ms");
	}
}